#!/usr/bin/env/python
""" 
Setup script for PyOsi added by Andrea Nerli
Copyright 2007 MBI srl
"""
DEBUG = True
#DEBUG = False

"""
OS dependent section
"""
from platform import system
import os

theOS = system()
if theOS == 'Windows':
    theECA = ['/GR']
    execfile('Windows.conf')
elif theOS == 'Linux':
    os.environ['CC']='g++'
    theECA = ['-fpermissive']
    execfile('Linux.conf')
else:
    print "Unknown OS! Aborting."
    exit(-1)
    
theMacros = []
theUnMacro = []
theInclude_dirs = [COINPATH_INC, BOOSTPATH_INC, MOSEKPATH_INC, CPLEXPATH_INC ]
theLibraries_dir = [COINPATH_LIB, BOOSTPATH_LIB, MOSEKPATH_LIB, CPLEXPATH_LIB ]

if not DEBUG:
    theMacros.append(('NDEBUG',None))
else:
    theUnMacro.append('NDEBUG')


from distutils.core import setup, Extension

CommonModule = Extension('pyOsi.pyOsiCommon',
                define_macros = theMacros,
                undef_macros = theUnMacro,
                extra_compile_args = theECA,
                include_dirs = theInclude_dirs,
                libraries = COMMON_LIB,
                library_dirs = theLibraries_dir,
                language = 'c++',
                sources = ['src/pyOsiCommon.cpp'])

CbcModule = Extension('pyOsi.pyOsiCbc',
                define_macros = theMacros,
                undef_macros = theUnMacro,
                extra_compile_args = theECA,
                include_dirs = theInclude_dirs,
                libraries = CBC_LIB,
                library_dirs = theLibraries_dir,
                sources = ['src/pyOsiCbc.cpp'])

ClpModule = Extension('pyOsi.pyOsiClp',
                define_macros = theMacros,
                undef_macros = theUnMacro,
                extra_compile_args = theECA,
                include_dirs = theInclude_dirs,
                libraries = CLP_LIB,
                library_dirs = theLibraries_dir,
                language = 'c++',
                sources = ['src/pyOsiClp.cpp'])

MskModule = Extension('pyOsi.pyOsiMsk',
                define_macros = theMacros,
                undef_macros = theUnMacro,
                extra_compile_args = theECA,
                include_dirs = theInclude_dirs,
                libraries = MSK_LIB,
                library_dirs = theLibraries_dir,
                language = 'c++',
                sources = ['src/pyOsiMsk.cpp'])

CpxModule = Extension('pyOsi.pyOsiCpx',
                define_macros = theMacros,
                undef_macros = theUnMacro,
                extra_compile_args = theECA,
                include_dirs = theInclude_dirs,
                libraries = CPX_LIB,
                library_dirs = theLibraries_dir,
                language = 'c++',
                sources = ['src/pyOsiCpx.cpp'])
                
setup(name="pyOsi",
      version="0.1",
      description="""pyOsi is a Python binding for the COIN-OR OpenSolverInterface.""",
      author="A. Nerli",
      author_email="a.nerli@mbigroup.it",
      url="http://code.google.com/p/pyosi",
      package_dir = {'pyOsi': 'src'},
      packages=['pyOsi'],
      ext_modules=[CommonModule,
                   CbcModule,
                   ClpModule,
                   MskModule,
                   CpxModule]
      )
